package org.thread.Homework;/*
 *@Author: gjh
 *Date: 2025/3/1019:31
 *Describe:
 */

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class MainTest {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        MyCallable oneHunderd = new MyCallable(1,100);
        MyCallable between = new MyCallable(101,900);
        MyCallable oneThousand = new MyCallable(901,1000);

        FutureTask<Integer> oh = new FutureTask<>(oneHunderd);
        FutureTask<Integer> bet = new FutureTask<>(between);
        FutureTask<Integer> ot = new FutureTask<>(oneThousand);

        Thread ohThread = new Thread(oh);
        Thread betThread = new Thread(bet);
        Thread otThread = new Thread(ot);

        ohThread.start();
        betThread.start();
        otThread.start();

        System.out.println("0-100的和："+oh.get());
        System.out.println("101-900的和："+bet.get());
        System.out.println("901-1000的和："+ot.get());
        System.out.println("1-1000的和：");
        System.out.println(oh.get()+bet.get()+ot.get());
    }
}
